<template>
  <div class="app-container">
    <el-form @submit.native.prevent :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px" :label-position="labelPosition">
      <el-form-item label="客户" prop="khmc">
        <el-input
          v-model="queryParams.khmc"
          placeholder="请输入客户"
          clearable
          @keyup.enter.native="enterClick"
        />
      </el-form-item>
     <el-form-item>
        <el-checkbox v-model="queryParams.all" label="显示所有客户" true-label="1" @change="getList"></el-checkbox>
        <el-checkbox v-model="queryParams.days" label="60日内到期" true-label="60" false-label="" @change="getList"></el-checkbox>
        <el-checkbox v-model="queryParams.expired" label="已到期" true-label="1" false-label="" @change="getList"></el-checkbox>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="getList">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table
      v-loading="loading"
      :data="contractFeeStandardList"
    >
      <af-table-column fixed="left" label="操作" align="center" class-name="small-padding fixed-width" width="120">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="contractFeeStandardDetail(scope.row)"
            v-hasPermi="['zhcloud:sfbz:detail']"
          >详细</el-button>
        </template>
      </af-table-column> 
      <af-table-column prop="khmc" label="客户名称" fixed="left"></af-table-column>
      <af-table-column prop="khlx" label="所在系统"></af-table-column>
      <af-table-column prop="ht1" label="合同尚未开始数量"></af-table-column>
      <af-table-column prop="ht2" label="合同正在进行数量"></af-table-column>
      <af-table-column prop="ht3" label="合同已经结束数量"></af-table-column>
      <af-table-column prop="ssrqidn" label="仓储租约到期日"></af-table-column>
    </el-table>
     <pagination
        v-show="total>0"
        :total="total"
        :page.sync="pageNum"
        :limit.sync="pageSize"
        @pagination="getList"
      />
  </div>
</template>

<script>
import { getContractFeeStandard } from "@/api/storage/contractFeeStandard";

export default {
  name: "ContractFeeStandard",
  data() {
    return {
      // 显示搜索条件
      showSearch: true,
      //表格加载
      loading:true,
       //对齐
      labelPosition: "right",
      // 查询参数
      queryParams: {
        khmc: "",
        all: "",
        days:"",
        expired:""
      },
      // 费用总览列表
      contractFeeStandardList: [],
      //页数
      pageSize: 10,
      //页码
      pageNum:1,
      // 总条数
      total: 0,
    };
  },
  beforeRouteEnter(to, from, next) {
    const params = to.params
    next(vm => {   
      if(Object.keys(params).length > 0) {
        if(to.params.refresh == true) {
          vm.getList()
        }
      }
    })
  },
  created() {
    this.getList()
  },
  methods: {
    
    /** 查询费用总览 */
    getList() {
      this.loading = true
      getContractFeeStandard(this.queryParams, {pageNum:this.pageNum, pageSize:this.pageSize}).then(response => {
        this.contractFeeStandardList = response.rows;
        this.total = response.total;
        this.loading = false
      })
    },

    /**详细 */
    contractFeeStandardDetail(row) {
      this.$router.push({path:"/storage/contractFeeStandard/contractDetail", query:{khid:row.khid, khmc:row.khmc}})
    },

    /**enter键触发 */
    enterClick(e) {
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.reset()
      this.getList()
    },
    reset() {
      Object.assign(this.$data, this.$options.data())
    },
  }
};
</script>
